/** *******************************************************************
 * FlexDatabaseManager
 * Copyright (c) 2008 Jonnie Spratley. All Rights Reserved.
 * @author  Jonnie Spratley
 * @contact jonniespratley@gmail.com
 * @internal
 ******************************************************************* */
package com.jonniespratley.flexdatabasemanager.vo
{
	import com.adobe.utils.DateUtil;
	
	import flash.net.SharedObject;
		
	[RemoteClass]
	[Bindable]
	public class UserVO
	{
		
		public var host:String;
		public var port:Number;
		public var username:String;
		public var password:String;
		public var fullname:String;
		public var description:String;
		public var email:String;
		public var info:String;
		public var icon:String;
			
		private var sharedO:SharedObject;
		private var sharedOData:UserVO;	
		
		public function  UserVO( 		
								host:String,
								port:Number, 
								username:String, 
								password:String,
								fullname:String = '',
								description:String = '',
								email:String = '',
								info:String = '',
								icon:String = '' )
		{			
			this.host = host;
			this.port = port
			this.username = username;
			this.password = password;
			
			if ( fullname != '' ) this.fullname = fullname;
			if ( description != '' ) this.description = description;
			if ( email != '' ) this.email = email;
			if ( info != '' ) this.info = info;
			
			if ( icon != null )
			{
				this.icon = icon;
			} 
				this.icon = '../../../assets/images/blank_avatar.jpeg';
			
			
		}
		
		public function saveThisObject( user:UserVO ):void
		{
			sharedO.data.user = user;
			sharedO.flush();
		}
		
		public function getSharedObject():UserVO
		{
			return sharedO.data.user;
		}
		
		public function getLoginDate():String
		{
			//Feb 12, 2009 3:32am
			var date:Date = new Date();
			var m:String = DateUtil.getShortMonthName( date );
			var d:String = String( date.getDay() );
			var y:String = String( date.getYear() );
			var h:String = String( DateUtil.getShortHour( date ) );
			var m:String = String( date.getMinutes() );
			var ampm:String = DateUtil.getAMPM( date );
			
			var newDate:String = newDate.concat( m, ' ', d, ', ', y, ' ', h, ':', m, ampm );
			
			return newDate; 
				
		}
		
	}
}